{template "header.html"}
<script>

    function dr_show_catid(catid) {
        if ($('.dr_cat_'+catid).is(":hidden")){
            $('.fc-cat-user').hide();
            $('.dr_cat_'+catid).show(200);
        }else{
            $('.dr_cat_'+catid).hide(200);
        }
    }
    function dr_copy_catid(catid) {
        dr_iframe('{dr_lang('复制')}', '{dr_url(APP_DIR.'/member/edit')}&catid='+catid);
    }
    $(function(){
            var table = $('.table-checkable');
            table.find('.group-checkable').change(function () {
                var set = jQuery(this).attr("data-set");
                var checked = jQuery(this).is(":checked");
                jQuery("."+set).each(function () {
                    if (checked) {
                        $(this).prop("checked", true);
                        $(this).parents('tr').addClass("active");
                    } else {
                        $(this).prop("checked", false);
                        $(this).parents('tr').removeClass("active");
                    }
                });
            });
    });
</script>
<div class="note note-danger  my-content-top-tool">
    <p><a href="javascript:dr_update_cache_all();">{dr_lang('更改数据之后需要更新缓存之后才能生效')}</a></p>
</div>

<div class="row finecms-tool-row">
    <div class="col-md-6">
        <div class="portlet light bordered">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-user font-dark"></i>
                    <span class="caption-subject font-dark  "> {dr_lang('模块访问权限')}</span>
                </div>
            </div>
            <div class="portlet-body form">
                <form id="form1">
                    {dr_form_hidden()}
                    <div class="form-body">
                        <div class="form-group">
                            <table class="fc-user-table table table-striped table-bordered table-checkable dataTable">
                                <thead>
                                <tr class="heading">
                                    <th class="myselect" style="height: 40px">
                                        <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                            <input type="checkbox" class="checkboxes group-checkable home" data-set="home" />
                                            <span></span>
                                        </label>
                                    </th>
                                    <th>

                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                {loop $list $i $t}
                                <tr class="odd gradeX">
                                    <td class="myselect">
                                        {if !$t.level}
                                        <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                            <input type="checkbox" {if !in_array($i, (array)$auth[home])} checked {/if} class="home checkboxes" name="id[]" value="{$i}" />
                                            <span></span>
                                        </label>
                                        {/if}
                                    </td>
                                    <td {$t.space}>{$t.name}</td>
                                </tr>
                                {/loop}
                                </tbody>
                            </table>
                            <div class="well"> {dr_lang('控制整个模块的访问权限，变更之后模块无法生成静态文件')} </div>
                        </div>
                        <div class="form-actions">
                            <button type="button" onclick="dr_submit_post_todo('form1', '{dr_url(APP_DIR.'/member/add')}&at=home')" class="btn blue"> <i class="fa fa-save"></i> {dr_lang('保存配置')}</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="col-md-6">
        <div class="portlet light bordered">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-search font-dark"></i>
                    <span class="caption-subject font-dark  "> {dr_lang('搜索权限')}</span>
                </div>
            </div>
            <div class="portlet-body form">
                <form id="form2">
                    {dr_form_hidden()}
                    <div class="form-body">
                        <div class="form-group">
                            <table class="fc-user-table table table-striped table-bordered table-checkable dataTable">
                                <thead>
                                <tr class="heading">
                                    <th class="myselect" style="height: 40px">
                                        <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                            <input type="checkbox" class="checkboxes group-checkable search" data-set="search" />
                                            <span></span>
                                        </label>
                                    </th>
                                    <th>

                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                {loop $list $i $t}
                                <tr class="odd gradeX">
                                    <td class="myselect">
                                        {if !$t.level}
                                        <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                            <input type="checkbox" {if !in_array($i, (array)$auth[search])} checked {/if} class="checkboxes search" name="id[]" value="{$i}" />
                                            <span></span>
                                        </label>
                                        {/if}
                                    </td>
                                    <td {$t.space}>{$t.name}</td>
                                </tr>
                                {/loop}
                                </tbody>
                            </table>
                        </div>
                        <div class="form-actions">
                            <button type="button" onclick="dr_submit_post_todo('form2', '{dr_url(APP_DIR.'/member/add')}&at=search')" class="btn blue"> <i class="fa fa-save"></i> {dr_lang('保存配置')}</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

    </div>
</div>

{if $categroy}
<div class="portlet light bordered ">
    <div class="portlet-title">
        <div class="caption">
            <i class="fa fa-reorder font-dark"></i>
            <span class="caption-subject font-dark"> {dr_lang('栏目权限')}</span>
        </div>
    </div>
    <div class="portlet-body form">
        <form id="form3">
            {dr_form_hidden()}
            <div class="form-body">
                <div class="form-group">
                    <table class="fc-user-table table table-striped table-bordered table-checkable dataTable">
                        <thead>
                        <tr class="heading">
                            <th class="myselect">Id</th>
                            <th>{dr_lang('栏目')}</th>
                            <th></th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $categroy $catid $cat}
                        <tr class="">
                            <td width="70"> {$cat.id}</td>
                            <td> {$cat.spacer} {$cat.name}</td>
                            <td>
                                <button onclick="dr_show_catid({$catid})" type="button" class="btn blue btn-xs"> <i class="fa fa-cog"></i> {dr_lang('用户权限')}</button>
                                <button onclick="dr_copy_catid({$catid})" type="button" class="btn green btn-xs"> <i class="fa fa-copy"></i> {dr_lang('复制权限')}</button>
                                <button onclick="dr_load_ajax('{dr_lang('你确定要初始化本栏目的权限配置吗？')}', '{dr_url(APP_DIR.'/member/del')}&catid={$catid}', 1)" type="button" class="btn red btn-xs"> <i class="fa fa-trash"></i> {dr_lang('初始化权限')}</button>

                            </td>
                        </tr>
                        <tr class="dr_cat_{$catid} fc-cat-user" style="display:none">
                            <td colspan="3" class="fc-cat-info">
                                <div class="table-scrollable">
                                    <table class="fc-cat-table table table-striped table-bordered  table-checkable dataTable">
                                        <thead>
                                        <tr class="heading">
                                            <th width="200" style="height: 40px"></th>
                                            <th class="fc-cat-select myselect ">{dr_lang('阅')}</th>
                                            {if $cat.is_post}
                                            <th class="fc-cat-select myselect ">{dr_lang('增')}</th>
                                            <th class="fc-cat-select myselect ">{dr_lang('改')}</th>
                                            <th class="fc-cat-select myselect ">{dr_lang('删')}</th>
                                            <th>{dr_lang('审核')}</th>
                                            <th>{dr_lang('经验值')}</th>
                                            <th>{dr_lang('虚拟币')}</th>
                                            <th>{dr_lang('日投稿')}</th>
                                            <th>{dr_lang('投稿总量')}</th>
                                            {else}
                                            <th colspan="99"></th>
                                            {/if}
                                        </tr>
                                        <tr class="heading">
                                            <th width="200"></th>
                                            <th class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes group-checkable dr_cat_{$catid}_show" data-set="dr_cat_{$catid}_show" />
                                                    <span></span>
                                                </label>
                                            </th>
                                            {if $cat.is_post}
                                            <th class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes group-checkable dr_cat_{$catid}_add" data-set="dr_cat_{$catid}_add" />
                                                    <span></span>
                                                </label>
                                            </th>
                                            <th class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes group-checkable dr_cat_{$catid}_edit" data-set="dr_cat_{$catid}_edit" />
                                                    <span></span>
                                                </label>
                                            </th>
                                            <th class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes group-checkable dr_cat_{$catid}_del" data-set="dr_cat_{$catid}_del" />
                                                    <span></span>
                                                </label>
                                            </th>
                                            <th></th>
                                            <th></th>
                                            <th></th>
                                            <th></th>
                                            <th></th>
                                            {else}
                                            <th colspan="99"></th>
                                            {/if}
                                        </tr>
                                        </thead>
                                        <tbody>
                                        {loop $list $i $t}
                                        <tr class="odd gradeX">
                                            {if $t.level}
                                            <td colspan="99"> {$t.name} </td>
                                            {else}
                                            <td {$t.space}>{$t.name}</td>
                                            <td class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes dr_cat_{$catid}_show" {if !in_array($i, (array)$auth[category][$cat.id]['show'])} checked {/if} name="id[{$cat.id}][show][]" value="{$i}" />
                                                    <span></span>
                                                </label>
                                            </td>
                                            {if $cat.is_post}
                                            <td class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes dr_cat_{$catid}_add" {if !in_array($i, (array)$auth[category][$cat.id]['add'])} checked {/if} name="id[{$cat.id}][add][]" value="{$i}"/>
                                                    <span></span>
                                                </label>
                                            </td>
                                            <td class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes dr_cat_{$catid}_edit" {if !in_array($i, (array)$auth[category][$cat.id]['edit'])} checked {/if} name="id[{$cat.id}][edit][]" value="{$i}" />
                                                    <span></span>
                                                </label>
                                            </td>
                                            <td class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes dr_cat_{$catid}_del" {if !in_array($i, (array)$auth[category][$cat.id]['del'])} checked {/if} name="id[{$cat.id}][del][]" value="{$i}" />
                                                    <span></span>
                                                </label>
                                            </td>
                                            <td>
                                                <select name="id[{$cat.id}][verify][{$i}]" class="form-control">
                                                    <option value="0"> -- </option>
                                                    {loop $verify $v}
                                                    <option value="{$v.id}" {if $auth[category][$cat.id]['verify'][$i] == $v.id} selected{/if}> {dr_lang($v.name)} </option>
                                                    {/loop}
                                                </select>
                                            </td>
                                            <td><input type="text" class="form-control" name="id[{$cat.id}][exp][{$i}]" value="{$auth[category][$cat.id]['exp'][$i]}" placeholder=""></td>
                                            <td><input type="text" class="form-control" name="id[{$cat.id}][score][{$i}]" value="{$auth[category][$cat.id]['score'][$i]}" placeholder=""></td>
                                            <td><input type="text" class="form-control" name="id[{$cat.id}][day_post][{$i}]" value="{$auth[category][$cat.id]['day_post'][$i]}" placeholder=""></td>
                                            <td><input type="text" class="form-control" name="id[{$cat.id}][total_post][{$i}]" value="{$auth[category][$cat.id]['total_post'][$i]}" placeholder=""></td>

                                            {else}
                                            <td colspan="99"></td>
                                            {/if}
                                            {/if}
                                        </tr>
                                        {/loop}
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                </div>
                <div class="form-actions text-center">
                    <button type="button" onclick="dr_submit_post_todo('form3', '{dr_url(APP_DIR.'/member/add')}&at=category')" class="btn blue"> <i class="fa fa-save"></i> {dr_lang('保存配置')}</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/if}

{if $form}
<div class="portlet light bordered ">
    <div class="portlet-title">
        <div class="caption">
            <i class="fa fa-list font-dark"></i>
            <span class="caption-subject font-dark"> {dr_lang('表单权限')}</span>
        </div>
    </div>
    <div class="portlet-body form">
        <form id="form7">
            {dr_form_hidden()}
            <div class="form-body">
                <div class="form-group">
                    <table class="fc-user-table table table-striped table-bordered table-checkable dataTable">
                        <thead>
                        <tr class="heading">
                            <th class="myselect">Id</th>
                            <th>{dr_lang('表单')}</th>
                            <th></th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $form $catid $cat}
                        <tr class="">
                            <td width="70"> {$catid}</td>
                            <td> {$cat.spacer} {$cat.name}</td>
                            <td>
                                <button onclick="dr_show_catid('{$catid}')" type="button" class="btn blue btn-xs"> <i class="fa fa-cog"></i> {dr_lang('用户权限')}</button>
                            </td>
                        </tr>
                        <tr class="dr_cat_{$catid} fc-cat-user" style="display:none">
                            <td colspan="3" class="fc-cat-info">
                                <div class="table-scrollable">
                                    <table class="fc-cat-table table table-striped table-bordered  table-checkable dataTable">
                                        <thead>
                                        <tr class="heading">
                                            <th width="200"></th>
                                            <th class="fc-cat-select myselect ">{dr_lang('阅')}</th>
                                            <th class="fc-cat-select myselect ">{dr_lang('增')}</th>
                                            <th class="fc-cat-select myselect ">{dr_lang('验')}</th>
                                            <th class="fc-cat-select myselect ">{dr_lang('审')}</th>
                                            <th>{dr_lang('经验值')}</th>
                                            <th>{dr_lang('虚拟币')}</th>
                                            <th>{dr_lang('日投稿')}</th>
                                            <th>{dr_lang('投稿总量')}</th>
                                        </tr>
                                        <tr class="heading">
                                            <th></th>
                                            <th class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes group-checkable dr_form_{$catid}_show" data-set="dr_form_{$catid}_show" />
                                                    <span></span>
                                                </label>
                                            </th>
                                            <th class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes group-checkable dr_form_{$catid}_add" data-set="dr_form_{$catid}_add" />
                                                    <span></span>
                                                </label>
                                            </th>
                                            <th class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes group-checkable dr_form_{$catid}_code" data-set="dr_form_{$catid}_code" />
                                                    <span></span>
                                                </label>
                                            </th>
                                            <th class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes group-checkable dr_form_{$catid}_verify" data-set="dr_form_{$catid}_verify" />
                                                    <span></span>
                                                </label>
                                            </th>
                                            <th>&nbsp;</th>
                                            <th>&nbsp;</th>
                                            <th>&nbsp;</th>
                                            <th>&nbsp;</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        {loop $list $i $t}
                                        <tr class="odd gradeX">
                                            {if $t.level}
                                            <td colspan="99"> {$t.name} </td>
                                            {else}
                                            <td {$t.space}>{$t.name}</td>
                                            <td class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes dr_form_{$catid}_show" {if !in_array($i, (array)$auth[form][$catid]['show'])} checked {/if} name="id[{$catid}][show][]" value="{$i}" />
                                                    <span></span>
                                                </label>
                                            </td>
                                            <td class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes dr_form_{$catid}_add" {if !in_array($i, (array)$auth[form][$catid]['add'])} checked {/if} name="id[{$catid}][add][]" value="{$i}"/>
                                                    <span></span>
                                                </label>
                                            </td>
                                            <td class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes dr_form_{$catid}_code" {if !in_array($i, (array)$auth[form][$catid]['code'])} checked {/if} name="id[{$catid}][code][]" value="{$i}" />
                                                    <span></span>
                                                </label>
                                            </td>
                                            <td class="fc-cat-select myselect anone">
                                                <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                    <input type="checkbox" class="checkboxes dr_form_{$catid}_verify" {if !in_array($i, (array)$auth[form][$catid]['verify'])} checked {/if} name="id[{$catid}][verify][]" value="{$i}" />
                                                    <span></span>
                                                </label>
                                            </td>
                                            <td><input type="text" class="form-control" name="id[{$catid}][exp][{$i}]" value="{$auth[form][$catid]['exp'][$i]}" placeholder=""></td>
                                            <td><input type="text" class="form-control" name="id[{$catid}][score][{$i}]" value="{$auth[form][$catid]['score'][$i]}" placeholder=""></td>
                                            <td><input type="text" class="form-control" name="id[{$catid}][day_post][{$i}]" value="{$auth[form][$catid]['day_post'][$i]}" placeholder=""></td>
                                            <td><input type="text" class="form-control" name="id[{$catid}][total_post][{$i}]" value="{$auth[form][$catid]['total_post'][$i]}" placeholder=""></td>
                                            {/if}
                                        </tr>
                                        {/loop}
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                </div>
                <div class="form-actions text-center">
                    <button type="button" onclick="dr_submit_post_todo('form7', '{dr_url(APP_DIR.'/member/add')}&at=form')" class="btn blue"> <i class="fa fa-save"></i> {dr_lang('保存配置')}</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/if}

{if $is_comment}
<div class="portlet light bordered ">
    <div class="portlet-title">
        <div class="caption">
            <i class="fa fa-comments font-dark"></i>
            <span class="caption-subject font-dark"> {dr_lang('评论权限')}</span>
        </div>
    </div>
    <div class="portlet-body form">
        <form id="form4">
            {dr_form_hidden()}
            <div class="form-body">
                <div class="form-group" style="padding-top: 0;">

                    <div class="table-scrollable">
                        <table class="fc-cat-table table table-striped table-bordered  table-checkable dataTable">
                            <thead>
                            <tr class="heading">
                                <th width="200"></th>
                                <th class="fc-cat-select myselect ">{dr_lang('评')}</th>
                                <th class="fc-cat-select myselect ">{dr_lang('审')}</th>
                                <th>{dr_lang('经验值')}</th>
                                <th>{dr_lang('虚拟币')}</th>
                            </tr>
                            <tr class="heading">
                                <th></th>
                                <th class="fc-cat-select myselect anone">
                                    <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                        <input type="checkbox" class="checkboxes group-checkable comment_add" data-set="comment_add" />
                                        <span></span>
                                    </label>
                                </th>
                                <th class="fc-cat-select myselect anone">
                                    <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                        <input type="checkbox" class="checkboxes group-checkable comment_verify" data-set="comment_verify" />
                                        <span></span>
                                    </label>
                                </th>
                                <th></th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>
                            {loop $list $i $t}
                            <tr class="odd gradeX">
                                {if $t.level}
                                <td colspan="99"> {$t.name} </td>
                                {else}
                                <td {$t.space}>{$t.name}</td>
                                <td class="fc-cat-select myselect anone">
                                    <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                        <input type="checkbox" class="checkboxes comment_add" {if !in_array($i, (array)$auth[comment]['add'])} checked {/if} name="id[add][]" value="{$i}" />
                                        <span></span>
                                    </label>
                                </td>
                                <td class="fc-cat-select myselect anone">
                                    <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                        <input type="checkbox" class="checkboxes comment_verify" {if !in_array($i, (array)$auth[comment]['verify'])} checked {/if} name="id[verify][]" value="{$i}" />
                                        <span></span>
                                    </label>
                                </td>
                                <td><input type="text" class="form-control" name="id[exp][{$i}]" value="{$auth[comment]['exp'][$i]}" placeholder=""></td>
                                <td><input type="text" class="form-control" name="id[score][{$i}]" value="{$auth[comment]['score'][$i]}" placeholder=""></td>
                                {/if}
                            </tr>
                            {/loop}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="form-actions text-center">
                    <button type="button" onclick="dr_submit_post_todo('form4', '{dr_url(APP_DIR.'/member/add')}&at=comment')" class="btn blue"> <i class="fa fa-save"></i> {dr_lang('保存配置')}</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/if}

<style>
.anone {
    vertical-align: baseline !important;
}
</style>
{template "footer.html"}